"use strict";

const {
  ModuleFederationPlugin,
} = require("@module-federation/enhanced/rspack");
const { rspack } = require("@rspack/core");
const { merge } = require("webpack-merge");
const ExternalTemplateRemotesPlugin = require("./rspack/plugin/ExternalTemplateRemotesRspackPlugin.cjs");
const common = require("./rspack.config.cjs");

/**
 * @type {import("@rspack/cli").Configuration}
 */
module.exports = merge(common, {
  output: {
    // 需要设置一个唯一值，不能和其他应用相等
    uniqueName: "ngV1_provider",
    // 使用 manifest 必须要配置 publicPath
    publicPath: `http://localhost:${process.env.PORT}/`,
  },
  plugins: [
    // new ModuleFederationPlugin({
    //   name: "ngV1_provider",
    //   exposes: {
    //     "./ngV1-app": "./src/index.ts",
    //   },
    //   shared: ["angular", "jquery"],
    // }),
    new rspack.container.ModuleFederationPlugin({
      name: "ngV1_app",
      remotes: {
        appSolid: "appSolid@http://localhost:7532/appSolidRemoteEntry.js",
      },
    }),
    // new ExternalTemplateRemotesPlugin(),
  ],
});
